//
//  SHMainController.swift
//  SHWeibo
//
//  Created by Cain on 16/7/19.
//  Copyright © 2016年 itcase. All rights reserved.
//

import UIKit

class SHMainController: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()


        //首页
        setChildController(SHHomeController(), title: "首页", imgName: "tabbar_home")
        //发现
        setChildController(SHDiscoverController(), title: "发现", imgName: "tabbar_discover")
        //消息
        setChildController(SHMessageController(), title: "消息", imgName: "tabbar_message_center")
        //我
        setChildController(SHProfileController(), title: "我", imgName: "tabbar_profile")
        
    }
    
    //MARK: - 封装标签栏控制器的初始化方法
    func setChildController(vc:SHVisitorController, title:String , imgName:String) {
        vc.navigationItem.title = title
        vc.title = title
        vc.tabBarItem.image = UIImage(named: imgName)
        //设置标签栏选中图片(图片渲染方式为源图渲染模式)
        vc.tabBarItem.selectedImage = UIImage(named: "\(imgName)_selected")?.imageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal)
        addChildViewController(UINavigationController(rootViewController: vc))
    }

}
